package com.example.demo.controller;

import com.example.demo.model.User;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import springfox.documentation.swagger2.annotations.EnableSwagger2;


@Api(value = "用户接口")
@RestController
public class UserController {

    private Logger logger = LoggerFactory.getLogger(this.getClass());


    @ApiOperation(value = "根据id查询用户信息", notes="服务用户首页", httpMethod = "GET")
    /*@ApiImplicitParams({@ApiImplicitParam(name = "id", value = "用户ID", required = true, dataType = "String", paramType = "query", example = "123456"),
            @ApiImplicitParam(name = "name", value = "用户name", required = false, dataType = "String", paramType = "query", example = "用户name")})*/
    @RequestMapping(value="/user/findUserById",method = RequestMethod.GET)
    public ModelAndView findUserById(@RequestBody User user, ModelAndView mv) throws Exception {
        mv.addObject("record", "this is swagger emp page");
        mv.setViewName("user");
        return mv;
    }


    @ApiOperation(value = "更新用户信息", notes="服务用户首页", httpMethod = "POST")
    /*@ApiImplicitParams({@ApiImplicitParam(name = "id", value = "用户ID", required = true, dataType = "String", paramType = "query", example = "123456"),
            @ApiImplicitParam(name = "name", value = "用户name", required = true, dataType = "String", paramType = "query", example = "用户name")})*/
    @RequestMapping(value="/user/updateUserById",method = RequestMethod.POST)
    public ModelAndView updateUserById(@RequestBody User user, ModelAndView mv) throws Exception {
        mv.addObject("record", "this is swagger emp page");
        mv.setViewName("user");
        return mv;
    }


}
